package com.atguigu.gmall.item.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController//后端将map中存储的key|value 以json的格式传到weball上进行渲染再传给前端
@RequestMapping("/api/item/")
public class ItemApiController {
    @Autowired
    private ItemService itemService;

    //获取sku 的详情信息
    @GetMapping("{skuId}")
    public Result getItem(@PathVariable Long skuId){
      Map<String, Object> map = itemService.getBySkuId(skuId);
        return Result.ok(map);
    }
}
